<!---
	Copyright 2010 Edward Trudeau, Jeremy Battle
    This software is freely available under the MIT License: http://www.opensource.org/licenses/mit-license.php
    http://ayc.googlecode.com
    
--->

<cfparam name="url.object" default="student" />
<cfparam name="url.id" default="0" />
<cfscript>
	ormReload();
	currentObject = entityNew(url.object);
</cfscript>


<cfmodule template="/mod/headerFooter.cfm">
<table id="myGrid"></table>
<div id="myGridPager"></div>
<div id="filterToolbar" style="margin-left:30%;display:none">Search Invoices</div> 
<script>
	
	var myGrid = jQuery("#myGrid").jqGrid({
		url:"search.cfm?object=<cfoutput>#url.object#</cfoutput>",
		datatype:"json",
		width:920,
		height:330,
		colNames:[<cfloop list="#currentObject.getDisplayColumns()#" index="cN">"<cfoutput>#currentObject.getFCData(cN).getLabelText()#</cfoutput>"<cfif cN NEQ listLen(currentObject.getDisplayColumns())>,</cfif></cfloop>],
		colModel:[
				<cfloop list="#currentObject.getDisplayColumns()#" index="cM">
				{<cfoutput>name:'#currentObject.getFCData(cM).getFieldName()#',index:'#currentObject.getFCData(cM).getFieldName()#',search:true,stype:'text'}<cfif cM NEQ listLen(currentObject.getDisplayColumns())>,</cfif></cfoutput>
				</cfloop>
		],
		rowNum:15,
		autowidth:true,
		ondblClickRow: function(id){ window.location = "<cfoutput>views/edit.cfm?object=#url.object#&id=</cfoutput>"+id;}, 
		mtype:"POST",
		rowList:[10,15,30],
		rownumbers:true,
		rownumWidth:40,
		pager:'#myGridPager',
		sortname: "<cfoutput>#ListGetAt(currentObject.getDisplayColumns(), 1)#</cfoutput>",
		viewrecords:true,
		sortorder:"desc",
		gridview:true,
		search:true,
		caption:"<cfoutput>Viewing #url.object#</cfoutput>"

	});
	myGrid.jqGrid('navGrid','#myGridPager',{edit:false,add:false,del:false,search:false,refresh:true}); 
	/*myGrid.jqGrid('navButtonAdd',"#myGridPager",{caption:"Toggle",title:"Toggle Search Toolbar", buttonicon :'ui-icon-pin-s', onClickButton:function(){ myGrid[0].toggleToolbar() } });*/
	myGrid.jqGrid('navButtonAdd',"#myGridPager",{caption:"Clear",title:"Clear Search",buttonicon :'ui-icon-clear', onClickButton:function(){ myGrid[0].clearToolbar() } }); 
	myGrid.jqGrid('filterToolbar'); 


</script>
</cfmodule>


